



////************
*California PPIC survey analysis for ``Learning to Love Government? Technological Change and the Political Economy of Higher Education''
******Journal of Politics

///Install packages
clear
ssc install maptile, replace
//maptile_install using "http://files.michaelstepner.com/geo_county1990.zip"
//maptile_install using "/Users/carlosxabel/Dropbox/HigherEd/Learning to love JOP data/maptile"
ssc install estout, replace
ssc install ivreg2, replace
ssc install ivreg2, replace
set scheme s2color, permanently

///Starting with home directory Learning to love JOP data/
//set working directory
//If needed  cd "~/Learning to love JOP data/"
//If needed  cd ../..




use "Data/20240213PPICconsolidated.dta", clear

cd "Output/3Calsurvey"

log using "3Log.smcl", replace

///Ignore this part if using full dataset	
	

	///since all are adults everybody with more than 15 years in the place was born there 

 
	///////////
	////Creating California-survey Figures
	/////////
	
	
///macros for individual and country controls	
global indivcontrols parent   homeowner collegegrad  white male
	

global countycontrols   l_shind_manuf_cbp   l_sh_popfborn l_sh_empl_f popdensity 




///Figure 3a Support for HE spending in California in PPIC surveys. Average support for HE spending in, by county subgroup

xtile q_logtotalrev90imp = logtotalrev90imp, nq(4)

//Manually defining cells by median values, but quartiles and thirds for investment
gen bin_routine33a=0 if l_sh_routine33aRebased<.3415866
replace bin_routine33a=1 if l_sh_routine33aRebased>=.3415866
	

	 
	 ///Different modelsof support by cell, quartiles
 reg ord_morefunding i.bin_routine33a##i.q_logtotalrev90imp $indivcontrols $countycontrols   i.surveyyear , r
     margins, over(bin_routine33a q_logtotalrev90imp   ) post

    coefplot,  recast(bar) ///
  vertical  graphregion(color(white)) ytitle("Support for more HE funding")   title(" ")   barwidth(0.5)  fcolor(*.5)   ciopts(recast(rcap)) citop ysc(r(2.40 2.62))   xline(4.5) level(90) ylabel(2.40 (.05) 2.65, nogrid)  ///
 xlabel(1 `" "Low routine X" "Q1 HE investment" "' 2 `" "Low routine X" "Q2 HE investment" "' 3 `" "Low routine X" "Q3 HE investment" "' 4 `" "Low routine X" "Q4 HE investment" "' 5 `" "High routine X" "Q1 HE investment" "' 6   `" "High routine X" "Q3 HE investment" "' 7 `" "High routine X" "Q4 HE investment" "' , labsize(small) angle(vertical) )   title(" ")
 
	 
	 graph export "SupportHEcellQuarters.png", replace
	 
drop bin_routine33a
drop q_logtotalrev90imp
	 
///Figure 3b: Support for HE spending in California in PPIC surveys.
//Correlates of support for HE spending in California’s public universities and colleges.

reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols $countycontrols republican i.surveyyear , cluster(czone)

 coefplot,   ///
  vertical  graphregion(color(white)) keep(c.l_sh_routine33aRebased#c.logtotalrev90impRebased parent collegegrad ) ytitle("Change in probabibility of supporting" " more public funding for HE")  title(" ")   fcolor(*.5)   ciopts(recast(rcap)) citop xscale(r(0.5  1.5))  yscale(r(-0.005 0.035))   ylabel(-0.005(.005)0.03) yline(0) xlabel(1 `" "Routine share" "ME Difference" "' 2 `" "Being a" "Parent" "' 3 `" "Being a" "College Graduate" "')
  
  
  graph export "SupportHEComparisonCoeffs.png", replace
  
  
  	//Figure B.3: Average levels of support for more investment in higher education, by California county 
	 ///predict levels of support while only including individual controls
	 reg sameormorefunding    $indivcontrols i.surveyyear, cluster(czone)
		predict sameormore_resid,residuals
		
		
		preserve
		collapse (mean) sameormorefunding sameormore_resid (first) State_FIPS, by(countyfips)
		gen county=countyfips
	
maptile sameormorefunding if State_FIPS==6, geo(county1990) mapif(State_FIPS==6) twopt(legend(pos(1))) geofolder("maptile")
	
		graph export CalsupportMap.pdf, replace 
restore

	  
  drop sameormore_resid
  
  /////////
  /////Tables Appendix C
  //////////
  


///Table C.12 Models of supporting state funding for California’s public colleges and universities –OLS Models with standard deviations

//Checked


eststo clear

*OLS with surveyyear fixed effects ---main model 
eststo clear
	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    i.surveyyear, cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear, cluster(czone)
eststo


*SD + Partisanship
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols republican i.surveyyear, cluster(czone)
eststo

*SD + Partisanship+ County controls
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols $countycontrols republican i.surveyyear , cluster(czone)
eststo


 esttab  est1 est2 est3 est4  using "CaliforniaSurveyOLSRebased.tex",    b(3) se(3) /// 
	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace  label    ///
order(  l_sh_routine33aRebased logtotalrev90impRebased)   interaction(" $\times$ ")  drop (   _cons  *.surveyyear) nonotes ///
	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
	
 ////Table C.13, Summary statistics (for California subsample, see Do-File 2.  County analysis)
 eststo clear
 
 sutex  l_sh_routine33a  logtotalrev90imp   , label minmax nobs file(SummaryCalifornia.tex) replace
  
	
	
	
	/////Table C.14 Models of supporting state funding for California’s public colleges and universities, restricted to California counties more representative of the country as a whole –OLS Models
	//EXCLUDING PARTICULAR COUNTIIES, top and bottom 10% nationally for routine 
	
	//Checked
	
	*OLS with surveyyear fixed effects ---main model 
eststo clear
	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    i.surveyyear if (l_sh_rout_natdc>1 & l_sh_rout_natdc<10), cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear if (l_sh_rout_natdc>1 & l_sh_rout_natdc<10), cluster(czone)
eststo


*SD + Partisanship
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols republican i.surveyyear if (l_sh_rout_natdc>1 & l_sh_rout_natdc<10), cluster(czone)
eststo

*SD + Partisanship+ County controls
  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols $countycontrols republican i.surveyyear if (l_sh_rout_natdc>1 & l_sh_rout_natdc<10), cluster(czone)
eststo


 esttab  est1 est2 est3 est4  using "CaliforniaSurveyOLSRebRestrictedCounties.tex",    b(3) se(3) /// 
	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace  label    ///
drop (   _cons  *.surveyyear) nonotes order(  l_sh_routine33aRebased logtotalrev90impRebased)  ///
	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
		
	
		///Table C.15 Models of supporting state funding for California’s public colleges and universities, for least likely subgroups –OLS Models	
	
	
		eststo clear
	//not college grads
	  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear if collegegrad==0, cluster(czone)
		eststo 
		
		//unemployed
	  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear if unemployed==1, cluster(czone)
	eststo
	
		//less than 50K 
	  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear if hhincometsd<=50, cluster(czone)
		eststo

		
		//republicans
	  	reg sameormorefunding  c.l_sh_routine33aRebased##c.logtotalrev90impRebased    $indivcontrols i.surveyyear if republican==1, cluster(czone)
		eststo 
		
	
		
		 esttab  est1 est2 est3 est4  using "CaliforniaSurveyOLSRebSubsets.tex",    b(3) se(3) /// 
	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace  label    ///
drop (   _cons  *.surveyyear) order(  l_sh_routine33aRebased logtotalrev90impRebased)  nonotes ///
	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
	
	
  
  //Table C.16: Models of supporting state funding for California’s public colleges and universities –OLS Models, raw data rather than SDs
  
  
*OLS with surveyyear fixed effects 
eststo clear
	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    i.surveyyear, cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols i.surveyyear, cluster(czone)
eststo


*SD + Partisanship
  	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols republican i.surveyyear, cluster(czone)
eststo

*SD + Partisanship+ County controls
  	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols $countycontrols republican i.surveyyear , cluster(czone)
eststo


esttab using "OLSmodelsRaw.tex", replace label se  drop (   _cons  *.surveyyear) order(    l_sh_routine33a logtotalrev90imp)   star(+ 0.1 * 0.05 ** 0.01 *** 0.001) nonotes  ///
	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
	



//Table C.17: Models of supporting funding –Probit Models

 
*Probit with surveyyear fixed effects ---main model
eststo clear
	probit sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    i.surveyyear, cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	probit sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols i.surveyyear, cluster(czone)
eststo


*SD + Partisanship
  	probit sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols republican i.surveyyear, cluster(czone)
eststo

*SD + Partisanship+ County controls
  	probit sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols $countycontrols republican i.surveyyear , cluster(czone)
eststo

 
  esttab  est1 est2 est3 est4  using "CaliforniaSurveyProbit.tex",    b(3) se(3) /// 
drop (   _cons  *.surveyyear)	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace  order(   l_sh_routine33a logtotalrev90imp)  label  nonotes  ///
	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
	
	
	

//Table C.18: Models of supporting state funding for California’s public colleges and universities –Ordered Probit Models

////notenoughfunding (three values, excludes 2019,2020)
*Ordered probit with surveyyear fixed effects ---main model
eststo clear
	oprobit notenoughfunding  c.l_sh_routine33a##c.logtotalrev90imp    i.surveyyear, cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	oprobit notenoughfunding c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols i.surveyyear, cluster(czone)
eststo


*SD + Partisanship
  	oprobit notenoughfunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols republican i.surveyyear, cluster(czone)
eststo

*SD + Partisanship+ County controls
  	oprobit notenoughfunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols $countycontrols republican i.surveyyear , cluster(czone)
eststo
 
 
  esttab  est1 est2 est3 est4  using "CaliforniaSurveyOProbit.tex",    b(3) se(3) /// 
	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace  order(   l_sh_routine33a logtotalrev90imp) label    ///
drop (     *.surveyyear) nonotes	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
 	

  
  ///Table C.19: Models of supporting state funding for California’s public colleges and universities, restricted to those who have resided in their current address for over 15 years –OLS Models	
    
////sameormorefunding (binary, excludes 2019,2020)
*OLS with surveyyear fixed effects ---main model 
eststo clear
	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    i.surveyyear if bornwherelives==1, cluster(czone)
eststo
 
 *Sociodemographic (SD) controls
  	reg sameormorefunding c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols i.surveyyear if bornwherelives==1, cluster(czone)
eststo


*SD + Partisanship
  	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols republican i.surveyyear if bornwherelives==1, cluster(czone)
eststo

*SD + Partisanship+ County controls
  	reg sameormorefunding  c.l_sh_routine33a##c.logtotalrev90imp    $indivcontrols $countycontrols republican i.surveyyear if bornwherelives==1, cluster(czone)
eststo


 esttab  est1 est2 est3 est4  using "CaliforniaSurveyOLSBornwherelives.tex",    b(3) se(3) /// 
	se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) order(  l_sh_routine33a logtotalrev90imp)  replace  label    ///
drop (   _cons  *.surveyyear) nonotes	addnotes("\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "Robust standard errors in parentheses.")
	
log close
  
  ////END
